package com.whnk.web.controller.model;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.whnk.common.annotation.Log;
import com.whnk.common.base.AjaxResult;
import com.whnk.common.enums.BusinessType;
import com.whnk.framework.web.base.BaseController;
import com.whnk.framework.web.page.TableDataInfo;
import com.whnk.model.domain.TModelParam;
import com.whnk.model.service.ITModelParamService;

/**
 * 模型参数 信息操作处理
 * 
 * @author whwhnk
 * @date 2021-05-28
 */
@Controller
@RequestMapping("/model/tModelParam")
public class TModelParamController extends BaseController
{
    private String prefix = "model/tModelParam";
	
	@Autowired
	private ITModelParamService tModelParamService;
	
	@RequiresPermissions("model:tModelParam:view")
	@GetMapping()
	public String tModelParam()
	{
	    return prefix + "/tModelParam";
	}
	
	/**
	 * 查询模型参数列表
	 */
	@RequiresPermissions("model:tModelParam:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TModelParam tModelParam)
	{
		startPage();
        List<TModelParam> list = tModelParamService.selectTModelParamList(tModelParam);
		return getDataTable(list);
	}
	
	/**
	 * 新增模型参数
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存模型参数
	 */
	@RequiresPermissions("model:tModelParam:add")
	@Log(title = "模型参数", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(TModelParam tModelParam)
	{		
		return toAjax(tModelParamService.insertTModelParam(tModelParam));
	}

	/**
	 * 修改模型参数
	 */
	@GetMapping("/edit/{iD}")
	public String edit(@PathVariable("iD") String iD, ModelMap mmap)
	{
		TModelParam tModelParam = tModelParamService.selectTModelParamById(iD);
		mmap.put("tModelParam", tModelParam);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存模型参数
	 */
	@RequiresPermissions("model:tModelParam:edit")
	@Log(title = "模型参数", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(TModelParam tModelParam)
	{		
		return toAjax(tModelParamService.updateTModelParam(tModelParam));
	}
	
	/**
	 * 删除模型参数
	 */
	@RequiresPermissions("model:tModelParam:remove")
	@Log(title = "模型参数", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(tModelParamService.deleteTModelParamByIds(ids));
	}
	
}
